package chapter3.lc11;

public class ContainerWithMostWater2 {
    public int maxArea(int[] height) {
        int maxArea = 0;
        for (int i = 0, j = height.length -1; i < j ;) {
            if (height[i] < height[j]) {
                maxArea = Math.max(maxArea, height[i] * (j - i));
                i++;
            }else {
                maxArea = Math.max(maxArea, height[j] * (j - i));
                j--;
            }
        }
        return maxArea;
    }
}
